package com.example.mybatis.service.impl;

import com.example.mybatis.dao.UserMapperExtend;
import com.example.mybatis.dto.UserDTO;
import com.example.mybatis.entity.User;
import com.example.mybatis.util.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapperExtend userMapper;

    @Override
    public List<UserDTO> getAllUser() {
        List<User> users = userMapper.selectByExample(null);
        List<UserDTO> userDTOS = new ArrayList<>(users.size());
        BeanUtils.copyList(users);
        return userDTOS;
    }
}
